const cookie = {
    setItem(key, value, ops={}){
        const p = ops.path ? ";path="+ops.path : "";
        let e = "";
        if(ops.expires){
            const d = new Date()
            d.setDate(d.getDate() + ops.expires);
            e = ";expires="+d;
        }
        document.cookie = `${key}=${value}${e}${p}`;
    },
    getItem(key){
        const arr = document.cookie.split("; ");
        for(let i=0;i<arr.length;i++){
            if(arr[i].split("=")[0] === key){
                return arr[i].split("=")[1];
            }
        }
        return null;
    },
    removeItem(key, ops={}){
        ops.expires = -1;
        this.setItem(key, "", ops);
    }
}